package com.cl.blog.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.cl.blog.common.Const;
import lombok.Data;

/**
 * @TableName b_user
 */
@TableName(value = "b_user")
@Data
public class BUser implements Serializable {
	/**
	 *
	 */
	@TableId(type = IdType.AUTO)
	private Integer id;

	/**
	 * 用户名
	 */
	private String nickname;

	/**
	 *
	 */
	private String username;

	/**
	 *
	 */
	private String password;

	private String description;

	/**
	 * 是否禁用
	 */
	private Integer isDelete = 0;

	/**
	 * 被访问量
	 */
	private Long visit;

	/**
	 * 关注数量
	 */
	private Long followCount = 0L;

	/**
	 * 获得点赞总数
	 */
	private Long likeCount = 0L;

	/**
	 *
	 */
	private String avatar;
	private LocalDateTime createTime = LocalDateTime.now();
	private LocalDateTime loginTime;
	@TableField(exist = false)
	private Integer score;

	/**
	 * 0（未登录），1（已登录）
	 */
	private Integer isLogin;
	private Long activeTime;
	private String emil;

	@TableField(exist = false)
	private String token;

	@TableField(exist = false)
	private Long follows;


	@TableField(exist = false)
	private String issuer = Const.GRADE_USER;


	@TableField(exist = false)
	private static final long serialVersionUID = 1L;

	@TableField(exist = false)
	private boolean isFollow = false;

	@Override
	public boolean equals(Object that) {
		if (this == that) {
			return true;
		}
		if (that == null) {
			return false;
		}
		if (getClass() != that.getClass()) {
			return false;
		}
		BUser other = (BUser) that;
		return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
				&& (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
				&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
				&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
				&& (this.getIsDelete() == null ? other.getIsDelete() == null : this.getIsDelete().equals(other.getIsDelete()))
				&& (this.getFollowCount() == null ? other.getFollowCount() == null : this.getFollowCount().equals(other.getFollowCount()))
				&& (this.getLikeCount() == null ? other.getLikeCount() == null : this.getLikeCount().equals(other.getLikeCount()))
				&& (this.getAvatar() == null ? other.getAvatar() == null : this.getAvatar().equals(other.getAvatar()))
				&& (this.getIsLogin() == null ? other.getIsLogin() == null : this.getIsLogin().equals(other.getIsLogin()));
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
		result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());
		result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
		result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
		result = prime * result + ((getIsDelete() == null) ? 0 : getIsDelete().hashCode());
		result = prime * result + ((getFollowCount() == null) ? 0 : getFollowCount().hashCode());
		result = prime * result + ((getLikeCount() == null) ? 0 : getLikeCount().hashCode());
		result = prime * result + ((getAvatar() == null) ? 0 : getAvatar().hashCode());
		result = prime * result + ((getIsLogin() == null) ? 0 : getIsLogin().hashCode());
		return result;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(getClass().getSimpleName());
		sb.append(" [");
		sb.append("Hash = ").append(hashCode());
		sb.append(", id=").append(id);
		sb.append(", nickname=").append(nickname);
		sb.append(", username=").append(username);
		sb.append(", password=").append(password);
		sb.append(", isDelete=").append(isDelete);
		sb.append(", followCount=").append(followCount);
		sb.append(", likeCount=").append(likeCount);
		sb.append(", avatar=").append(avatar);
		sb.append(", isLogin=").append(isLogin);
		sb.append(", serialVersionUID=").append(serialVersionUID);
		sb.append("]");
		return sb.toString();
	}
}